////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  afdtuning.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "afdtuning.h"
#include "parametersetmanager.h"

AFDTUNING_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatix_auto_flicker_detection_data_typeClass::chromatix_auto_flicker_detection_data_typeClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(frame_ct_threshold);
    PARAMETER_INITIALIZE(frame_smooth_detection_thr);
    PARAMETER_INITIALIZE(frame_smooth_ct_threshold);
    PARAMETER_INITIALIZE(num_frames);
    PARAMETER_INITIALIZE(frame_skip);
    PARAMETER_INITIALIZE(num_rows);
    PARAMETER_INITIALIZE(num_cols);
    PARAMETER_INITIALIZE(switch_on_first_detection);
    PARAMETER_INITIALIZE(max_attempts_for_second_detection);
    PARAMETER_INITIALIZE(AFD_continuous_enable);
    PARAMETER_INITIALIZE(num_frames_settle);
    PARAMETER_INITIALIZE(start_antbanding_table);
    PARAMETER_INITIALIZE(max_exp_time_ms);
    PARAMETER_INITIALIZE(afd_low_light_trigger);
    PARAMETER_INITIALIZE(afd_rolling_normal);
    PARAMETER_INITIALIZE(afd_rolling_lowlight);
    PARAMETER_INITIALIZE(afd_static_normal);
    PARAMETER_INITIALIZE(afd_static_lowlight);
    PARAMETER_INITIALIZE(afd_scd_normal);
    PARAMETER_INITIALIZE(afd_scd_lowlight);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatix_auto_flicker_detection_data_typeClass::chromatix_auto_flicker_detection_data_typeClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(frame_ct_threshold);
    PARAMETER_INITIALIZE(frame_smooth_detection_thr);
    PARAMETER_INITIALIZE(frame_smooth_ct_threshold);
    PARAMETER_INITIALIZE(num_frames);
    PARAMETER_INITIALIZE(frame_skip);
    PARAMETER_INITIALIZE(num_rows);
    PARAMETER_INITIALIZE(num_cols);
    PARAMETER_INITIALIZE(switch_on_first_detection);
    PARAMETER_INITIALIZE(max_attempts_for_second_detection);
    PARAMETER_INITIALIZE(AFD_continuous_enable);
    PARAMETER_INITIALIZE(num_frames_settle);
    PARAMETER_INITIALIZE(start_antbanding_table);
    PARAMETER_INITIALIZE(max_exp_time_ms);
    PARAMETER_INITIALIZE(afd_low_light_trigger);
    PARAMETER_INITIALIZE(afd_rolling_normal);
    PARAMETER_INITIALIZE(afd_rolling_lowlight);
    PARAMETER_INITIALIZE(afd_static_normal);
    PARAMETER_INITIALIZE(afd_static_lowlight);
    PARAMETER_INITIALIZE(afd_scd_normal);
    PARAMETER_INITIALIZE(afd_scd_lowlight);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatix_auto_flicker_detection_data_typeClass::~chromatix_auto_flicker_detection_data_typeClass()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* chromatix_auto_flicker_detection_data_typeClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "ChromatixAFDTuningData")) == 0)
    {
        name = "ChromatixAFDTuningData";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load trigger_point_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatix_auto_flicker_detection_data_typeClass::Loadtrigger_point_type(
    ParameterFileSymbolTableEntry* entry,
    trigger_point_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt64(&structure->lux_index_start);
    result = result && entry->ReadInt64(&structure->lux_index_end);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatix_afd_rolling_data_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatix_auto_flicker_detection_data_typeClass::Loadchromatix_afd_rolling_data_type(
    ParameterFileSymbolTableEntry* entry,
    chromatix_afd_rolling_data_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadFloat(&structure->std_threshold);
    result = result && entry->ReadInt32(&structure->percent_threshold);
    result = result && entry->ReadUInt64(&structure->diff_threshold);
    result = result && entry->ReadInt32(&structure->num_peaks_threshold);
    result = result && entry->ReadFloat(&structure->band_dist_comp);
    result = result && entry->ReadFloat(&structure->band_range_min);
    result = result && entry->ReadFloat(&structure->band_range_max);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatix_afd_scd_data_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatix_auto_flicker_detection_data_typeClass::Loadchromatix_afd_scd_data_type(
    ParameterFileSymbolTableEntry* entry,
    chromatix_afd_scd_data_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->sad_thr);
    result = result && entry->ReadInt32(&structure->sadr_thr);
    result = result && entry->ReadInt32(&structure->sad_max_frame);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatix_afd_static_data_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatix_auto_flicker_detection_data_typeClass::Loadchromatix_afd_static_data_type(
    ParameterFileSymbolTableEntry* entry,
    chromatix_afd_static_data_type* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->thldLevel2Ratio);
    result = result && entry->ReadInt32(&structure->thldLevel3Ratio);
    result = result && entry->ReadInt32(&structure->thldLevel2Col);
    result = result && entry->ReadInt32(&structure->thldLevel3Col);
    result = result && entry->ReadInt32(&structure->thldEkL);
    result = result && entry->ReadInt32(&structure->thldEkU);
    result = result && entry->ReadInt32(&structure->thldCounterL3);
    result = result && entry->ReadInt32(&structure->thldCounterL2);
    result = result && entry->ReadInt32(&structure->LevelDepth);
    result = result && entry->ReadInt32(&structure->static_step_size);
    result = result && entry->ReadInt32(&structure->static_down_size);
    result = result && entry->ReadInt32(&structure->static_k_step);
    result = result && entry->ReadInt32(&structure->static_slope_steep_thr);
    result = result && entry->ReadInt32(&structure->static_slope_not_steep_thr);
    result = result && entry->ReadFloat(&structure->static_confidence_level_slope_ratio);
    result = result && entry->ReadInt32(&structure->static_confidence_thr_h);
    result = result && entry->ReadInt32(&structure->static_confidence_thr_l);
    result = result && entry->ReadFloat(&structure->static_confidence_ratio_h);
    result = result && entry->ReadFloat(&structure->static_confidence_ratio_l);
    result = result && entry->ReadInt32(&structure->static_low_rowsum_thr);
    result = result && entry->ReadInt32(&structure->static_low_rowsum_comp);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatix_auto_flicker_detection_data_type
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatix_auto_flicker_detection_data_typeClass::Loadchromatix_auto_flicker_detection_data_type(
    ParameterFileSymbolTableEntry* entry,
    chromatix_auto_flicker_detection_data_type* structure)
{
    BOOL result = TRUE;
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);
    result = result && entry->ReadUInt64(&structure->frame_ct_threshold);
    result = result && entry->ReadInt32(&structure->frame_smooth_detection_thr);
    result = result && entry->ReadInt32(&structure->frame_smooth_ct_threshold);
    result = result && entry->ReadInt32(&structure->num_frames);
    result = result && entry->ReadInt32(&structure->frame_skip);
    result = result && entry->ReadInt32(&structure->num_rows);
    result = result && entry->ReadInt32(&structure->num_cols);
    result = result && entry->ReadBoolean(&structure->switch_on_first_detection);
    result = result && entry->ReadInt32(&structure->max_attempts_for_second_detection);
    result = result && entry->ReadBoolean(&structure->AFD_continuous_enable);
    result = result && entry->ReadInt32(&structure->num_frames_settle);
    result = result && entry->ReadInt32(&structure->start_antbanding_table);
    result = result && entry->ReadFloat(&structure->max_exp_time_ms);
    result = result && Loadtrigger_point_type(entry, &structure->afd_low_light_trigger);
    result = result && Loadchromatix_afd_rolling_data_type(entry, &structure->afd_rolling_normal);
    result = result && Loadchromatix_afd_rolling_data_type(entry, &structure->afd_rolling_lowlight);
    result = result && Loadchromatix_afd_static_data_type(entry, &structure->afd_static_normal);
    result = result && Loadchromatix_afd_static_data_type(entry, &structure->afd_static_lowlight);
    result = result && Loadchromatix_afd_scd_data_type(entry, &structure->afd_scd_normal);
    result = result && Loadchromatix_afd_scd_data_type(entry, &structure->afd_scd_lowlight);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatix_auto_flicker_detection_data_typeClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatix_auto_flicker_detection_data_type::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);
    result = result && entry->ReadInt32(&structure->incr_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* chromatix_auto_flicker_detection_data_typeClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    chromatix_auto_flicker_detection_data_typeClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW chromatix_auto_flicker_detection_data_typeClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && Loadchromatix_auto_flicker_detection_data_type(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


AFDTUNING_NAMESPACE_END
